package com.test.webmanage.controller;

import com.test.webmanage.pojo.Dept;
import com.test.webmanage.pojo.Result;
import com.test.webmanage.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@Slf4j
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;
//    @RequestMapping(value = "/depts",method = RequestMethod.GET)
    @GetMapping("/depts")
    public Result list(){
//        log.info("查询所有部门");
        System.out.println("查询所有部门");
        List<Dept> depts = deptService.list();
        return Result.success(depts);
    }
    @DeleteMapping("/depts/{id}")
    public Result delete(@PathVariable Integer id){
        deptService.delete(id);
        return Result.success();
    }
    @PostMapping("/depts")
    public Result add(@RequestBody Dept dept){
        deptService.add(dept);
        return Result.success();
    }

}
